package com.example.administrator.myapplication;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.administrator.myapplication.Util.DB;

/**
 * Created by Administrator on 2020/12/10.
 */

public class SignInActivity extends AppCompatActivity {

    private EditText signInUsernameEt;
    private EditText signStudentIdEt;
    private Button signInBtn;
    private String usernamestr;
    private String studentStr;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);
        initView();
        initEvent();
    }
    private void initView(){
        signInUsernameEt = findViewById(R.id.sign_in_username_et);
        signStudentIdEt = findViewById(R.id.sign_in_student_id_et);
        signInBtn = findViewById(R.id.sign_in_btn);
    }
    private void initData(){
        usernamestr = signInUsernameEt.getText().toString()+"";
        studentStr = signStudentIdEt.getText().toString()+"";

    }
    private void  initEvent(){
         signInBtn.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 initData();
                 DB db = new DB(SignInActivity.this);
                 db.signInInsert(usernamestr,studentStr);

                    Toast.makeText(SignInActivity.this,""+usernamestr+""+studentStr,Toast.LENGTH_SHORT).show();

             }
         });
    }

}
